home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / batch / tsbat36.zip / C.BAT < prev    next >
DOS Batch File  |  1992-07-30  |  1KB  |  47 lines

  1. echo off
  2. echo Lazy changing of directory
  3. echo By Prof. Timo Salmi, ts@uwasa.fi, Thu 30-Jul-1992
  4. echo.
  5.  
  6. rem If you are fed up with typing \ in changing the directory
  7. rem with the cd command, this is the batch for you
  8.  
  9. rem E.g. if you have a directory \text\jokes\stupid the just use
  10. rem c text jokes stupid
  11. rem Applying c without parameters takes you to the root directory
  12. rem Drive can be an optional first parameter, e.g. c d: text jokes stupid
  13.  
  14. set drive_=
  15. for %%d in (a b c d e f g h i j k l m n o p q r s t u v x y z) do if "%1"=="%%d:" set drive_=%%d:
  16. if "%drive_%"=="" goto _set_dir
  17.  
  18. if not exist %drive_%\nul goto _err_driv
  19. echo Changing drive to %drive_%
  20. %drive_%
  21. shift
  22.  
  23. :_set_dir
  24. set dir_=
  25. :_loop
  26. set dir_=%dir_%\%1
  27. shift
  28. if not "%1"=="" goto _loop
  29.  
  30. if not "%dir_%"=="\" if not exist %dir_%\nul goto _err_dir
  31.  
  32. echo Changing directory to %dir_%
  33. cd %dir_%
  34. goto _out
  35.  
  36. :_err_driv
  37. echo Drive %drive_% does not exist
  38. goto _out
  39.  
  40. :_err_dir
  41. echo Directory %dir_% does not exist
  42.  
  43. :_out
  44. set drive_=
  45. set dir_=
  46. echo on
  47.